﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DynORM.ConfigExtensions
{
    public class DatabaseConfigSection : ConfigurationSection
    {
        private static DatabaseConfigSection settings = ConfigurationManager.GetSection("DatabaseConfigSection") as DatabaseConfigSection;

        public static DatabaseConfigSection Settings
        {
            get
            {
                return settings;
            }
        }

        [ConfigurationProperty("connectionString", IsRequired = true)]
        //[StringValidator(MinLength = 1, MaxLength = 256)]
        //setting MinLength without default value causes exception 
        [StringValidator(MaxLength = 256)]
        public string ConnectionString
        {
            get { return (string)this["connectionString"]; }
            set { this["connectionString"] = value; }
        }


        [ConfigurationProperty("DBMS", IsRequired = true)]
        //[StringValidator(InvalidCharacters = " ~!@#$%^&*()[]{}/;’\"|\\", MinLength = 1, MaxLength = 256)]
        //setting MinLength without default value causes exception 
        [StringValidator(InvalidCharacters = " ~!@#$%^&*()[]{}/;’\"|\\", MaxLength = 256)]
        public string DBMS
        {
            get { return (string)this["DBMS"]; }
            set { this["DBMS"] = value; }
        }
    }
}
